package com.py.test.obj;

import com.protobuftest.protobuf.ChatProbuf;

public class Chat {
	private int id;
	private long time;
	private String send_id;
	private String send_name;
	private int send_vip;
	private String msg;
	private byte[] data; 
	public Chat(int id) {
		this.id = id;
	}
	public Chat(int id, String msg) {
		this.id = id;
		this.msg = msg;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public long getTime() {
		return time;
	}
	public void setTime(long time) {
		this.time = time;
	}
	public String getSend_id() {
		return send_id;
	}
	public void setSend_id(String send_id) {
		this.send_id = send_id;
	}
	public String getSend_name() {
		return send_name;
	}
	public void setSend_name(String send_name) {
		this.send_name = send_name;
	}
	public int getSend_vip() {
		return send_vip;
	}
	public void setSend_vip(int send_vip) {
		this.send_vip = send_vip;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	@Override
	public String toString() {
		return this.getId() + ":" + msg;
	}
	public byte[] getData() {
		if (data == null) {
			data = toByte();
		}
		return data;
	}
	public void setData(byte[] data) {
		this.data = data;
	}
	
	public byte[] toByte() {
		ChatProbuf.Chat.Builder build = ChatProbuf.Chat.newBuilder();
		build.setId(getId());
		build.setMsg(msg);
		ChatProbuf.Chat proChat = build.build();
		return proChat.toByteArray();
	}
}
